#ifndef __GLOBALAPI_H__
#define __GLOBALAPI_H__

#include <arpa/inet.h>
#include <net/if.h>
#include <netdb.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <time.h>

#include "zlog.h"

typedef struct {
    uint16_t year;
    uint8_t mon;
    uint8_t day;
    uint8_t hour;
    uint8_t min;
    uint8_t sec;
    uint8_t week;
} dataTime;

void charToHexStringWithSpace(char *tag, unsigned char buf[], int len);
int uint32ToCharBig(unsigned char buf[], int bufLen, uint32_t val);
int uint32ToCharLittle(unsigned char buf[], int bufLen, uint32_t val);
int uint16ToCharBig(unsigned char buf[], int bufLen, uint16_t val);
int uint16ToCharLitter(unsigned char buf[], int bufLen, uint16_t val);
int CharBigToInteger(unsigned char buf[], int bufLen, uint32_t *val);
int CharLitterToInteger(unsigned char buf[], int bufLen, uint32_t *val);
int decStrLitterToInteger(unsigned char buf[], int bufLen, int *val);
uint8_t Ascii2Hex(unsigned char *ascii, uint8_t len, unsigned char *hex);
uint16_t clareCalcCrc(unsigned char *data, unsigned len);
void ascii_to_integer(unsigned char *str, unsigned char *des);
int getMacaddr(char mac[], int type);
int SecToDate(uint32_t sec, dataTime *rtcDate);
uint32_t dateToSec(uint16_t year, uint8_t mon, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec);
char *bitValOfChar(uint8_t bit, uint8_t val);
char *bitVal(bool bit);
void utcTime();
int get_ip_by_domain(const char *domain, char *ip);
int get_local_mac(const char *eth_inf, unsigned char *mac);
int get_local_ip(const char *eth_inf, char *ip);
int getContinuInterval(uint8_t buf[], int len, int offset, uint8_t *startIndex, uint8_t *endIndex);
int shellCommand(char *cmd, char *reply, int reply_len, bool respone, bool wait);
int Rb_mtx_init();
int Rb_mtx_cancel();
char *redbee_strtok(char *s, const char *ct);
#endif
